/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "detalle_orden")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetalleOrden.findAll", query = "SELECT d FROM DetalleOrden d"),
    @NamedQuery(name = "DetalleOrden.findByIdDetalleOrden", query = "SELECT d FROM DetalleOrden d WHERE d.idDetalleOrden = :idDetalleOrden"),
    @NamedQuery(name = "DetalleOrden.findByCantidad", query = "SELECT d FROM DetalleOrden d WHERE d.cantidad = :cantidad"),
    @NamedQuery(name = "DetalleOrden.findByPrecio", query = "SELECT d FROM DetalleOrden d WHERE d.precio = :precio"),
    @NamedQuery(name = "DetalleOrden.findByObservacion", query = "SELECT d FROM DetalleOrden d WHERE d.observacion = :observacion")})
public class DetalleOrden implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Detalle_Orden")
    private Integer idDetalleOrden;
    @Column(name = "Cantidad")
    private Integer cantidad;
    @Size(max = 11)
    @Column(name = "Precio")
    private String precio;
    @Size(max = 60)
    @Column(name = "Observacion")
    private String observacion;
    @JoinColumn(name = "Cod_Prod_Prov", referencedColumnName = "Cod_Prod_Prov")
    @ManyToOne(optional = false)
    private ProductosProv codProdProv;
    @JoinColumn(name = "id_Orden_Compra", referencedColumnName = "id_Orden_Compra")
    @ManyToOne(optional = false)
    private OrdenCompra idOrdenCompra;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDetalleOrden")
    private Collection<TallerProvProd> tallerProvProdCollection;

    public DetalleOrden() {
    }

    public DetalleOrden(Integer idDetalleOrden) {
        this.idDetalleOrden = idDetalleOrden;
    }

    public Integer getIdDetalleOrden() {
        return idDetalleOrden;
    }

    public void setIdDetalleOrden(Integer idDetalleOrden) {
        this.idDetalleOrden = idDetalleOrden;
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }

    public String getPrecio() {
        return precio;
    }

    public void setPrecio(String precio) {
        this.precio = precio;
    }

    public String getObservacion() {
        return observacion;
    }

    public void setObservacion(String observacion) {
        this.observacion = observacion;
    }

    public ProductosProv getCodProdProv() {
        return codProdProv;
    }

    public void setCodProdProv(ProductosProv codProdProv) {
        this.codProdProv = codProdProv;
    }

    public OrdenCompra getIdOrdenCompra() {
        return idOrdenCompra;
    }

    public void setIdOrdenCompra(OrdenCompra idOrdenCompra) {
        this.idOrdenCompra = idOrdenCompra;
    }

    @XmlTransient
    public Collection<TallerProvProd> getTallerProvProdCollection() {
        return tallerProvProdCollection;
    }

    public void setTallerProvProdCollection(Collection<TallerProvProd> tallerProvProdCollection) {
        this.tallerProvProdCollection = tallerProvProdCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetalleOrden != null ? idDetalleOrden.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleOrden)) {
            return false;
        }
        DetalleOrden other = (DetalleOrden) object;
        if ((this.idDetalleOrden == null && other.idDetalleOrden != null) || (this.idDetalleOrden != null && !this.idDetalleOrden.equals(other.idDetalleOrden))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.DetalleOrden[ idDetalleOrden=" + idDetalleOrden + " ]";
    }
    
}
